package com.fetch.test;


import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.regex.Pattern;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;

public class GetInfo {
	
	public static void main(String[] args) throws Exception {
//		001000032944
//		222921165362
		for(int i=0; i<50; i++){
			String COOKIE = "ASP.NET_SessionId=wjswjou2kzjhfv55x4s1nu55; UserInfo=cardmunber=001000032009&logins=102&searchs=43636&FIRST_DATE=2013-12-11&END_DATE=2014-12-11&IS_ZZ=0&CORP_NAME=%e4%b8%80%e9%be%99&ADDS=%e9%87%91%e6%b2%b3%e5%9b%bd%e9%99%85%e5%a4%a7%e5%8e%a6&LINKMAN=%e4%b8%80%e9%be%99&TEL=15358836061; FengYe=RowCount=318308&PageCount=5788";
			HttpClient client = new HttpClient();
			PostMethod postMethod = null;
			try{
				postMethod = new PostMethod("http://218.4.189.213:8001/CorpSel/Corp_info.aspx?corp_id=2113565");
				postMethod.addRequestHeader("Cookie", COOKIE);
				
				int code = client.executeMethod(postMethod);
				String result = postMethod.getResponseBodyAsString();
//				writeFile(result);
				System.out.println(result.indexOf("/login.aspx"));
//				System.out.println(Pattern.compile("InfoShowImg.aspx\\?StrCode=.+\"").matcher(result).find());
				Thread.sleep(1000*60*2);
			}catch (Exception e) {
				e.printStackTrace();
			}finally{
				postMethod.releaseConnection();
			}
		}
	}
	
	
	private static void writeFile(String s) throws Exception{
		FileOutputStream fos = new FileOutputStream("f:/test.html");
		fos.write(s.getBytes());
		fos.close();
	}
	
}
